<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
<body>
<div id="root">
    <table>
        <thead></thead>
        <tbody>
        <tr is="row"></tr>
        <tr is="row"></tr>
        <tr is="row"></tr>
        </tbody>
    </table>


    <br>
    <hr>
    <counter ref="one" @change="addVal"></counter>
    <counter ref="two" @change="addVal"></counter>
    <p>{{sum}}</p>
</div>

</body>
<script>
    Vue.component("row", {
        data: function () {
            return {
                msg: "Hello Vue!"
            }

        },
        template: "<tr><td v-text='msg'></td></tr>"
    })


    Vue.component("counter", {
        data: function () {
            return {
                number: 0
            }
        },
        template: "<a href='javascript://' @click='getVal' v-text='number'></a>",
        methods: {
            getVal: function () {
                this.number++
                this.$emit("change")
            }
        }
    })
    var vm = new Vue({
        el: '#root',
        data:{
            sum:0
        },
        methods: {
            addVal: function () {
                this.sum=this.$refs.one.number+this.$refs.two.number;
                console.log(this.$refs.one.number);
            }
        }
    })
</script>
</html>